/**
 * 数据库配置
 */
const mysql = require('mysql2');

const config = {
  host: process.env.DB_HOST,
  port: process.env.DB_PORT,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
  connectTimeout: process.env.DB_TIMEOUT,
  // timezone: "+08:00",
  dateStrings: true, // 默认false将被解析为Date对象格式2023-11-27T03:39:09.164Z
};

const pool = mysql.createPool(config);
const poolPromise = pool.promise();

module.exports = {
  pool,
  poolPromise,
};
